Conversation
…aria-labelledby/alt Before: for <input type="image">, <object>, and <area>, the rule checked only for the PRESENCE of an accessible-name fallback attribute (aria-label / aria-labelledby / alt / title). An empty-string value provides no accessible name but slipped past. Fix: add hasNonEmptyTextAttr() that requires the attribute's static value to be non-whitespace. Dynamic values (mustache, concat) remain accepted — we can't tell at lint time whether they resolve to empty. <img>'s alt handling is unchanged — alt="" is still valid there (spec-defined marker for decorative images). Nine new invalid tests cover the three elements × three fallback attrs.
🏎️ Benchmark Comparison
Full mitata output |
Translates 41 cases from peer-plugin rules:
- jsx-a11y alt-text
- vuejs-accessibility alt-text
- lit-a11y alt-text
Fixture documents parity after this fix:
- Empty-string aria-label/aria-labelledby on <object>, <area>, and
<input type=image> is now flagged (reusing existing objectMissing /
areaMissing / inputImage messageIds).
Remaining divergences (<img alt role=presentation> accepting non-empty
alt in jsx-a11y, <img aria-label> without alt) are annotated inline.
Owner
Author
|
Moved upstream to ember-cli#2730. See that PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
aria-label=""/aria-labelledby=""/alt=""/title=""contributes no accessible name (per accname + HTML-AAM — the linked §mapping_additional_nd_name coversaria-labelexplicitly, andaria-labelledby/alt/titleinherit via HTML-AAM). For<input type="image">,<object>, and<area>, an accessible name is required.<input type="image" aria-label="" />was accepted.Fix: add
hasNonEmptyTextAttr()that requires a static value to be non-whitespace. Dynamic values (mustache, concat) stay accepted — we can't know at lint time whether they resolve to empty.<img>'salt=""is unchanged — an emptyalton<img>is spec-defined as a marker for decorative images.Nine new invalid tests (3 elements × 3 fallback attrs) cover the fix.
Prior art
alt-textobject/area/input[type=image]handlers treat emptyaria-labelas missing viaariaLabelHasValue. Empty-label validation in theimghandler uses inline string messages (noariaLabelValueError/ariaLabelledbyValueErrormessageIds).alt-textalt-text!elementHasAttribute(element, 'alt'); does NOT validate that aria-label / aria-labelledby are non-empty.Our fix reuses the existing error messages (
inputImage,objectMissing,areaMissing); we don't split into a separate empty-label error. That's an improvement we could make later.Upstream
ember-template-lint@7.9.3has the same false negative.